package com.example.bootdemo.service.impl;

import com.example.bootdemo.pojo.UserBlogEntity;
import com.example.bootdemo.pojo.UserBlogKey;
import com.example.bootdemo.repository.UserBlogRepository;
import com.example.bootdemo.service.UserBlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class UserBlogServiceImpl implements UserBlogService {

    @Autowired
    private UserBlogRepository userBlogRepository;

    @Override
    public UserBlogEntity findById(UserBlogKey blogKey) {

        return userBlogRepository.findById(blogKey).get();
    }

    @Override
    @Transactional
    public UserBlogEntity saveOne(UserBlogEntity userBlogEntity) {

        return userBlogRepository.save(userBlogEntity);
    }

    @Override
    @Transactional
    public List<UserBlogEntity> saveAll(List<UserBlogEntity> userBlogEntities) {

        return userBlogRepository.saveAll(userBlogEntities);
    }
}
